import { Injectable } from '@angular/core';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';

@Injectable()
export class DataService {

  export_url = 'http://localhost/phpexcel/export.php';
  export_url2 = 'http://localhost/phpexcel/export2.php';

  sation_device: any;
  other_device: any;
  assisted: any;

  file: any;

  constructor(private http: HttpClient) {

  }

  export_excel() {
    let p = new HttpParams().set('title', 'data')
      .set('sation', JSON.stringify(this.sation_device))
      .set('other', JSON.stringify(this.other_device))
      .set('assisted', JSON.stringify(this.assisted));

    let headers = new HttpHeaders({
      'Content-type': 'application/x-www-form-urlencoded;charset=utf-8'
    });
      this.http.post(this.export_url2, p, {headers}).subscribe(data => {
        console.log(data);
        // this.file = data;
      });

  }
}
